import { defineStore } from "pinia";
import { useCountStore } from "./count";

export const useTalkStore = defineStore('talk', {
    state() {
        return {
            talkList: [
                { id: 'ftrasdws01', title: '今天你有点怪，哪里怪？怪好看的！' },
                { id: 'ftrasdws02', title: '草莓，蓝莓，蔓越莓，今天想我了没？' },
                { id: 'ftrasdws03', title: '心里给你留了一块地，我的死心塌地' },
            ],
            user: [
                {
                    id: 1,
                    name: '张三',
                },
                {
                    id: 2,
                    name: '李四',
                }
            ]
        }
    },
    getters: {
        // 返回函数并进行传递参数
        getUserById(state) {
            return (id: number) => state.user.find(item => item.id === id);
        },
        // 获取countStore的getter的值
        countGetter(state) {
            const countStore = useCountStore();
            return state.user[0].name + '--' + countStore.doubleCount;
        }
    },
})